import Axios from "axios";

export const API_URL = "";
const service = Axios.create({
    baseURL: `${API_URL}/api`,
});
service.interceptors.response.use(
    (response) => {
        const apiData = response.data;

        const code = apiData.code;
        // 如果没有 code, 代表这不是项目后端开发的 api
        if (code === undefined)
            return Promise.reject(new Error("非本系统的接口"));

        switch (code) {
            case 200:
                return apiData.data;
        }
    },
    (error) => {
        return Promise.reject(error);
    }
);
export default service;
